package exercises.Charpter10;

interface Cycle{
	void ride();
}

interface CycleFactory{
	Cycle getCycle ();
}

class UnicycleFactory implements CycleFactory{

	public Cycle getCycle() {
		return new Cycle() {
			public void ride() {
				System.out.println("Unicycle ride");
			}
		};
	}
}

class BicycleFactory implements CycleFactory{
	public Cycle getCycle() {
		return new Cycle() {
			public void ride() {
				System.out.println("Bicycle ride");
			}
		};
	}
}

class TricycleFactory implements CycleFactory{
	public Cycle getCycle() {
		return new Cycle(){
			public void ride() {
				System.out.println("Tricycle ride");
			}
		};
	}
}

public class Sixteen {
	public static void ride(CycleFactory myFactory){
		Cycle myCycle = myFactory.getCycle();
		myCycle.ride();
	}
	
	public static void main(String[] args){
		ride(new UnicycleFactory());
		ride(new BicycleFactory());
		ride(new TricycleFactory());
	}
}
